import Vue from 'vue'
import App from './App.vue'
import router from './router'

import axios from 'axios'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// 引入自体图标文件
import './assets/fonts/iconfont.css'
// 全局css文件
import './assets/css/global.css'

// 商品分类树形组件的依赖
import ZkTable from 'vue-table-with-tree-grid'

// 导入vue-quill-editor（富文本编辑器）
import VueQuillEditor from 'vue-quill-editor'
// 导入vue-quill-editor的样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

import moment from 'moment'

Vue.use(VueQuillEditor /* { default global options } */)
Vue.component('tree-table', ZkTable)

axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'

// 请求拦截器
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
}, error => {
  return Promise.reject(error)
})
Vue.prototype.$http = axios

Vue.use(ElementUI)

Vue.config.productionTip = false

// 时间过滤器
Vue.filter('dateFormat', (val) => {
  return moment.unix(val).format('YYYY-MM-DD')
})

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
